package top.superflow.core.pool.rdb

import java.sql.Connection

import com.zaxxer.hikari.HikariDataSource
import top.superflow.core.pool.ResourceAction
import top.superflow.exception.RequestUnsupportedException

class HikariResourceAction(hikariDataSource : HikariDataSource) extends ResourceAction[Connection] {

  validate(hikariDataSource)

  def validate(hikariDataSource : HikariDataSource): Unit ={
    if(hikariDataSource == null){
      throw new RequestUnsupportedException(hikariDataSource)
    }

    //other validation
  }


  override def get: Connection = {
    hikariDataSource.getConnection
  }

  override def evict(t: Connection): Unit = {
    hikariDataSource.evictConnection(t)
  }

}
